#pragma once
#include <iostream>
#include <string>
#include <unistd.h>


class channel
{
public:
    channel(int wfd,pid_t who):_wfd(wfd),_who(who)
    {
        _name="chanel-"+std::to_string(wfd)+"-"+std::to_string(who);
    }
    void send(int cmd)
    {
        ::write(_wfd, &cmd, sizeof(cmd));
    }
    std::string name()
    {
        return _name;
    }
    pid_t id()
    {
        return _who;
    }
    int wfd()
    {
        return _wfd;
    }
    void close()
    {
        ::close(_wfd);
    }
    ~channel()
    {

    }

private:
    int _wfd;
    std::string _name;
    pid_t _who;
};